package com.cheyunkeji.er.adapter;

import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

/**
 * Created by Michael on 2017/2/24 9:40.
 * custom Adapter for ViewPager to change Fragment automatically
 */

public class MyFragmentPagerAdapter extends FragmentPagerAdapter {

    private List<String> titleList;
    private List<Fragment> fraList;

    public MyFragmentPagerAdapter(FragmentManager fm, List<String> titleList, List<Fragment> fraList) {
        super(fm);
        this.fraList = fraList;
        this.titleList = titleList;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titleList.get(position);
    }

    @Override
    public Fragment getItem(int position) {
        return fraList.get(position);
    }

    @Override
    public int getCount() {
        return titleList.size();
    }

}
